package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerCostEstimation;
import com.shrcl.engineerprocess.domain.EngineerCostEstimationDocument;
import com.shrcl.engineerprocess.domain.impl.EngineerCostEstimationImpl;
import com.shrcl.engineerprocess.domain.proxy.EngineerCostEstimationDocumentProxy;
import edu.fudan.langlab.domain.document.IDocumentContainer;
import edu.fudan.langlab.domain.document.impl.DocumentStorageImpl;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("ENGINEERCOSTESTIMATIONDOCUMENT_TYPE")
public class EngineerCostEstimationDocumentImpl extends DocumentStorageImpl implements EngineerCostEstimationDocument {
  public EngineerCostEstimationDocumentImpl() {
    super();
  }
  
  public EngineerCostEstimationDocumentImpl(final EngineerCostEstimation engineerCostEstimation) {
    super();
    this.engineerCostEstimation = engineerCostEstimation;
  }
  
  @JoinColumn(name = "engineerCostEstimation_id")
  @ManyToOne(targetEntity = EngineerCostEstimationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerCostEstimation engineerCostEstimation;
  
  public EngineerCostEstimation getEngineerCostEstimation() {
    return this.engineerCostEstimation;
  }
  
  public EngineerCostEstimationDocument setEngineerCostEstimation(final EngineerCostEstimation engineerCostEstimation) {
    this.engineerCostEstimation = engineerCostEstimation;
    return this;			
    
  }
  
  public IDocumentContainer getContainer() {
    return this.engineerCostEstimation;
  }
  
  public static EngineerCostEstimationDocument create(final EngineerCostEstimation engineerCostEstimation, final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.EngineerCostEstimationDocument engineerCostEstimationDocument = new com.shrcl.engineerprocess.domain.impl.EngineerCostEstimationDocumentImpl(
    	engineerCostEstimation
    );
    objectFactory.create(engineerCostEstimationDocument);
    return engineerCostEstimationDocument;			
    
  }
  
  public static EngineerCostEstimationDocument createEngineerCostEstimationDocumentImpl(final EngineerCostEstimation engineerCostEstimation, final IObjectFactory objectFactory, final Procedure1<EngineerCostEstimationDocument> init) {
    com.shrcl.engineerprocess.domain.EngineerCostEstimationDocument engineerCostEstimationDocument = new com.shrcl.engineerprocess.domain.impl.EngineerCostEstimationDocumentImpl(
    	engineerCostEstimation
    );
    objectFactory.create(engineerCostEstimationDocument);
    init.apply(engineerCostEstimationDocument);
    
    return engineerCostEstimationDocument;			
    
  }
  
  public EngineerCostEstimationDocumentProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.EngineerCostEstimationDocumentProxy proxy = new com.shrcl.engineerprocess.domain.proxy.EngineerCostEstimationDocumentProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
